﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace POVRay {
    public class ColorMap : Block {
        public Dictionary<float, Color> Colors { get; set; }

        public ColorMap() {
            Colors = new Dictionary<float, Color>();
        }

        public ColorMap(Dictionary<float, Color> colors) {
            Colors = colors;
        }

        public void Add(float key, Color value) {
            Colors.Add(key, value);
        }

        public override string ToString(int level) {
            StringBuilder sb = new StringBuilder();
            sb.Append("color_map { ");

            foreach (var keyValuePair in Colors) {
                float key = keyValuePair.Key;
                Color value = keyValuePair.Value;
                sb.Append(Scene.Indentation(level + 1) + "[" + key.POVRayString() + " " + value.ToString() + "] ");
            }

            sb.Append(Scene.Indentation(level) + "}");
            return sb.ToString();
        }
    }
}
